import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { List, Avatar ,Table, Tag, Space,Button,Modal,Form, Input, Row ,Col, Checkbox } from 'antd';
export default class ReportInfoForm extends Component {


    constructor(props) {
        super(props)
        this.state = {
            //value:this.props.valueObj.text,  //文本
            value:this.props.initValues,  //文本
        }
    }

    closeSelf=()=>{
        this.props.onCancel();
    }

    confirm=()=>{
        //alert(this.state.value)
        let  _v=this.state.value;
        this.props.handleSave(_v);



    }


    /**
     * Handle pressing a key when the Cell is an input element
     */
    // onKeyPressOnInput = (e) => {
    //     if (e.key === 'Enter') {
    //         this.hasNewValue(e.target.value)
    //     }
    // }

    /**
     * Handle moving away from a cell, stores the new value
     */
    // onBlur = (e) => {
    //     this.hasNewValue(e.target.value)
    // }

    /**
     * Called by the `onBlur` or `onKeyPressOnInput` event handlers,
     * it escalates the value changed event, and restore the editing state
     * to `false`.
     */
    // hasNewValue = (value) => {
    //     this.props.onChangedCell(
    //         value,
    //     )
    //     //       this.setState({ editing: false })
    // }


    /**
     * When a Cell value changes, re-determine the display value
     * by calling the formula calculation
     */
    onChange = (e) => {
        this.setState({ value: e.target.value })
        // this.display = this.determineDisplay({ x: this.props.x, y: this.props.y }, e.target.value)
        // this.props.updateCells()
    }


    render() {
       // const {getFieldDecorator} = this.props.form;
        const formItemLayout = {
            labelCol: {span: 6},
            wrapperCol: {span: 18},
        };

        return (
            <Modal
                width={740}
                title="新增"
                visible={this.props.visible}
                confirmLoading={this.props.confirmLoading}
               // onOk={this.props.handleSave}
                //okText='保存'
                cancelText='返回'
                onCancel={this.props.onCancel}
                footer={null}
            >
                <Form>
                    <Row gutter={16}>
                        <Col span={24}>
                            <Form.Item
                                label="报表名称"
                                name="reportName"
                                rules={[{ required: true, message: 'Please input your report Name!' }]}
                            >
                                <Input
                                    //onBlur={this.onBlur}
                                    //onKeyPress={this.onKeyPressOnInput}
                                    value={this.state.value}
                                    onChange={this.onChange}
                                    autoFocus
                                />
                            </Form.Item>
                        </Col>
                    </Row>
                    <Row>
                        <Col span={16}></Col>
                        <Col span={3}><Button type="primary" onClick={this.confirm}>确定</Button></Col>
                        <Col span={3}><Button onClick={this.closeSelf}>取消</Button></Col>
                        <Col span={2}></Col>
                    </Row>



                </Form>
            </Modal>
        );
    }
}

// ReportInfoForm.propTypes = {
//     title: PropTypes.string.isRequired,
//     visible: PropTypes.bool,
//     initValues: PropTypes.object,
//     onCancel: PropTypes.func,
//     handleSave: PropTypes.func,
//     confirmLoading: PropTypes.bool
// };
